<extend name="Public/base" />
<block name="body" >
    <div class="main_sub wrap_w">
    <div class="crumbs"><em>当前位置：</em><a href="{:U('Game/gift_list')}">独家礼包</a></div>
    <div class="gameclass">
        <h2 class="titi">礼包<span>分类</span></h2>
        <ul class="gameclasslist">
            <li><span>热门游戏</span>
                <p> 
					<a href="{:U('Game/gift_list')}" class="<if condition='$game_id == 0 '>curr</if>">不限</a>
					<foreach name="gift_list" item="gl" >
					<a href="{:U('Game/gift_list?game_id='.$gl['game_id'].'')}" class="<if condition='$game_id == $gl[game_id]'>curr</if>">
                        {$gl.game_name}
                    </a>					
					</foreach>
									
				</p>
            </li>
        </ul>
    </div>
    <div id="giftlist">
        <ul class="clearfix" id = "content">
        <volist name="list_data" id="vo">
            <li>
                <div class="l">
                    <a href="{:U('Game/game_detail?id='.$vo['game_id'].'')}">
                        <img src="{$vo.icon|get_cover='path'}">
                    </a>
                </div>
                <div class="r">
                    <h3>{$vo.giftbag_name}-<?php echo preg_replace('/(\(.+)/i','',$vo['game_name']);?></h3>
                    <p class="ct">
                        {$vo.desribe}
                    </p>
                    <p class="cm">
                        <if condition="$vo['end_time']-time() gt 0">
                        剩余有效期：{:ceil(($vo['end_time']-time())/86400);}天
						<else/>
                        剩余有效期：0天
                        </if>
                    </p>
                    <div class="bn">
                        <a onclick="XGUC.get_game_gift({$vo.id}, &#39;{$vo.giftbag_name}&#39;)" target="_blank">
                            领取礼包
                        </a>
                    </div>
                </div>
            </li>
        </volist>    
        </ul>
    </div>
    <div class="page">
        {$_page|default=''}  
	</div>
</div>
<script type="text/javascript" src="/Public/static/jquery-2.0.3.min.js"></script>
<script>
    $(document).ready(function () {
        get_gift_list();
    });

    function get_gift_list()
    {
        $.ajax({
            url: "html/gifts/gift.json",
            type: "GET",
            dataType: "json",
            success: function (data) {
                var str = '';
                for(var p in data){
                        str += '<li>' +
                        '                <div class="l">' +
                        '                    <a href="/html/games/game_details/'+data[p]['game_id']+'.html">' +
                        '                       <img src='+data[p]["icon"]+'>' +
                        '                    </a>' +
                        '                </div>' +
                        '                <div class="r">' +
                        '                    <h3>'+data[p]['giftbag_name']+'-'+data[p]['game_name']+'</h3>' +
                        '                    <p class="ct">' +
                        '                                            </p>' +
                        '                    <p class="cm">' +
                        '                                                剩余有效期：'+data[p]["remaining_time"]+'天                    </p>' +
                        '                    <div class="bn">' +
                        '                        <a onclick="XGUC.get_game_gift('+data[p]['id']+', &#39;'+data[p]['giftbag_name']+'&#39;)" target="_blank">' +
                        '                            领取礼包' +
                        '                        </a>' +
                        '                    </div>' +
                        '                </div>' +
                        '            </li>';
                }
                $('#content').html(str);
            }
        });
    }
</script>
</block>